GtkWidget *headerbar;
GtkWidget *action_area;
- gboolean use_header_bar;
+ gint use_header_bar;
gboolean constructed;
};
static void
set_use_header_bar (GtkDialog *dialog,
- gboolean use_header_bar)
+ gint use_header_bar)
{
GtkDialogPrivate *priv = dialog->priv;
+ if (use_header_bar == -1)
+ return;
+
priv->use_header_bar = use_header_bar;
+}
+
+/* A convenience helper for built-in dialogs */
+void
+gtk_dialog_set_use_header_bar_from_setting (GtkDialog *dialog)
+{
+ GtkDialogPrivate *priv = dialog->priv;
+
+ g_assert (!priv->constructed);
+
+ g_object_get (gtk_widget_get_settings (GTK_WIDGET (dialog)),
+ "gtk-dialogs-use-header", &priv->use_header_bar,
+ NULL);
+}
+
+static void
+apply_use_header_bar (GtkDialog *dialog)
+{
+ GtkDialogPrivate *priv = dialog->priv;
+
gtk_widget_set_visible (priv->action_area, !priv->use_header_bar);
gtk_widget_set_visible (priv->headerbar, priv->use_header_bar);
if (!priv->use_header_bar)
switch (prop_id)
{
case PROP_USE_HEADER_BAR:
- set_use_header_bar (dialog, g_value_get_boolean (value));
+ set_use_header_bar (dialog, g_value_get_int (value));
break;
default:
switch (prop_id)
{
case PROP_USE_HEADER_BAR:
- g_value_set_boolean (value, priv->use_header_bar);
+ g_value_set_int (value, priv->use_header_bar);
break;
default:
priv = dialog->priv;
priv->constructed = TRUE;
+ if (priv->use_header_bar == -1)
+ priv->use_header_bar = FALSE;
add_action_widgets (dialog);
+ apply_use_header_bar (dialog);
return object;
}
* %TRUE if the dialog uses a #GtkHeaderBar for action buttons
* instead of the action-area.
*
+ * For technical reasons, this property is declared as an integer
+ * property, but you should only set it to %TRUE or %FALSE.
+ *
* Since: 3.12
*/
g_object_class_install_property (gobject_class,
PROP_USE_HEADER_BAR,
- g_param_spec_boolean ("use-header-bar",
- P_("Use Header Bar"),
- P_("Use Header Bar for actions."),
- FALSE,
- GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
+ g_param_spec_int ("use-header-bar",
+ P_("Use Header Bar"),
+ P_("Use Header Bar for actions."),
+ -1, 1, -1,
+ GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
binding_set = gtk_binding_set_by_class (class);
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "close", 0);
{
dialog->priv = gtk_dialog_get_instance_private (dialog);
+ dialog->priv->use_header_bar = -1;
+
gtk_widget_init_template (GTK_WIDGET (dialog));
update_spacings (dialog);
gint first_response_id,
...)
{
+ GtkDialogPrivate *priv = dialog->priv;
va_list args;
g_return_if_fail (GTK_IS_DIALOG (dialog));
- if (dialog->priv->use_header_bar)
+ if (priv->constructed && priv->use_header_bar)
return;
if (!gtk_alt_dialog_button_order ())
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __GTK_DIALOG_PRIVATE_H__
+#define __GTK_DIALOG_PRIVATE_H__
+
+#include "gtkdialog.h"
+
+G_BEGIN_DECLS
+
+void gtk_dialog_set_use_header_bar_from_setting (GtkDialog *dialog);
+
+G_END_DECLS
+
+#endif /* __GTK_DIALOG_PRIVATE_H__ */